package pro.spring.controller.backController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("switch")
public class SwitchController extends BaseController{
	
	
	@ResponseBody
	@RequestMapping(value="open.json",method=RequestMethod.POST)
	public Integer open(HttpServletRequest request,
			HttpServletResponse response){
		Integer num = 0;
		num = switchService.switchOpen();
		Integer type = switchService.selectType();
		HttpSession session=request.getSession();
		session.setAttribute("switch",type);
		return num ;
	}
	
	
	@ResponseBody
	@RequestMapping(value="close.json",method=RequestMethod.POST)
	public Integer close(HttpServletRequest request,
			HttpServletResponse response){
		Integer num = 0;
		num = switchService.switchClose();
		Integer type = switchService.selectType();
		HttpSession session=request.getSession();
		session.setAttribute("switch",type);
		return num ;
	} 
}
